<?php

class SysException extends Exception {
    
   public function __construct($message = 0, $code = 0)
   {
       parent::__construct($message, $code);
   }

   // Overloaded function
   public function __toString()
   {
       $msg =  "<h1>" . get_class($this) . "</h1>\n<p>";
       
       if ($this->message) $msg .= "<b>Message:</b> $this->message";
       if ($this->code) $msg .= "\n<br><b>Code:</b> $this->code";
       
       $msg .= "\n<br><b>Source:</b> " . $this->getFile() . "<b>, line </b>" . $this->getLine();
       $msg .= "\n<br><b>Backtrace:</b> " . $this->getTraceAsString();

       $msg .= "</p>";
       return $msg;
   }
}

function my_exception_handler($exception)
{
    print $exception;
}

set_exception_handler('my_exception_handler');

?>